/*
 * 轻量级js dom操作库
 */

/**
 * 是否是IE
 * @type 
 */
var IS_IE = !+'\v1';
// 全局变量
var $mind;
if(typeof $mind == 'undefined'){
	$mind = new arongjs();
}
function arongjs() {
	// 重载1
	this.ajax = function(conf) {
		// 初始化
		var type = conf.type;
		var url = conf.url;
		var data = conf.data;
		var dataType = conf.dataType;
		var success = conf.success;
		// 用于构造load函数
		var ele = conf.element;

		if (type == null)
			type = "get";
		if (dataType == null)
			dataType = "text";
		// 创建ajax引擎对象
		var xhr = this.createAjax();
		// 打开
		xhr.open(type, url, true);
		// 发送
		if (type == "GET" || type == "get") {
			xhr.send(null);
		} else if (type == "POST" || type == "post") {
			xhr.setRequestHeader("content-type",
					"application/x-www-form-urlencoded");
			xhr.send(data);
		}
		xhr.onreadystatechange = function() {
			if (xhr.readyState == 4 && xhr.status == 200) {
				if (dataType == "text" || dataType == "TEXT") {
					if (ele != null)
						// load函数效果
						ele.html(xhr.responseText);
					if (success != null)
						success(xhr.responseText);

				} else if (dataType == "xml" || dataType == "XML") {
					if (success != null)
						success(xhr.responseXML);
				} else if (dataType == "json" || dataType == "JSON") {
					if (success != null)
						success(eval("(" + xhr.responseText + ")"));
				}
			}
		};
	};

	// 重载2
	this.ajax2 = function() {
		var type = "get";
		var url = null;
		var dataType = "text";
		var data = null;
		var success = null;
		if (arguments.length == 1) {
			if (arguments[0].constructor == String) {
				url = arguments[0];
			}
		}
		if (arguments.length == 2) {
			if (arguments[0].constructor == String
					&& arguments[1].constructor == Function) {
				url = arguments[0];
				success = arguments[1];
			} else if (arguments[0].constructor == Function
					&& arguments[1].constructor == String) {
				url = arguments[1];
				success = arguments[0];
			}
		}
		if (arguments.length == 3) {
			if (arguments[0].constructor == String
					&& arguments[1].constructor == String
					&& arguments[2].constructor == Function) {
				url = arguments[0];
				dataType = arguments[1];
				success = arguments[2];
			}
		}
		if (arguments.length == 4) {
			url = arguments[0];
			dataType = arguments[1];
			data = arguments[2];
			success = arguments[3];
		}
		if (arguments.length == 5) {
			type = arguments[0];
			url = arguments[1];
			dataType = arguments[2];
			data = arguments[3];
			success = arguments[4];
		}
		// 开始处理ajax
		// 创建ajax引擎对象
		var xhr = this.createAjax();
		// 打开
		xhr.open(type, url, true);
		// 发送
		if (type == "GET" || type == "get") {
			xhr.send(null);
		} else if (type == "POST" || type == "post") {
			xhr.setRequestHeader("content-type",
					"application/x-www-form-urlencoded");
			xhr.send(data);
		}
		xhr.onreadystatechange = function() {
			if (xhr.readyState == 4 && xhr.status == 200) {
				if (dataType == "text" || dataType == "TEXT") {
					success(xhr.responseText);
				} else if (dataType == "xml" || dataType == "XML") {
					success(xhr.responseXML);
				} else if (dataType == "json" || dataType == "JSON") {
					success(eval("(" + xhr.responseText + ")"));
				}
			}
		};
	};
	// 去除字符串的所有空格
	this.nospace = function(s) {
		if(s == null){
			return null;
		}
		return s.replace(/\s+/g, "");
	};
	
	this.trim = function(s){
		if(s != null && typeof s == 'string'){
			return s.replace(/(^\s*)|(\s*$)/g, "");
		}
		return s;
	}

	// 判断指定的数组中是否包含某个对象
	this.contains = function(strArr, str) {
		if (strArr.constructor == Array) {
			for ( var i = 0; i < strArr.length; i++) {
				if (strArr[i] == this.nospace(str)) {
					return true;
				}
			}
		}
		return false;
	};

	// 对象是否为空
	this.isEmpty = function(o){
		if(o != null && typeof o != 'undefined' && o != 'undefined' && this.trim(o) != "" ){
			return false;
		}
		return true;
	}
	// 去掉oldstyle中与newstyle重复的属性
	this.styleReplace = function(oldstyle, newstyle){
		if(newstyle == null || this.trim(newstyle) == "" || oldstyle == null || this.trim(oldstyle) == ""){
			return oldstyle;
		}
		oldstyle = oldstyle.toLowerCase();//"display:none;position:relative;overflow:hidden;"
		newstyle = newstyle.toLowerCase();//"display:block;"
		var news = newstyle.split(";");
		for(var i = 0; i < news.length; i++){
			var key = this.nospace(news[i].split(":")[0]);
			if(key == ""){
				continue;
			}
			var index = oldstyle.indexOf(key);
			if(index != -1){
				var s1 = oldstyle.substr(0, index - 1);//""
				var s2 = oldstyle.substr(index + key.length, oldstyle.length);//":none;position:relative;overflow:hidden;"
				if(s2.indexOf(";") != -1){
					oldstyle = s1 + (s1 != "" ? ";" : "") + s2.replace(s2.split(";")[0] + ";", "");
				}else{
					oldstyle = s1;
				}
			}
		}
		return oldstyle;
	}
	this.nextSpecialNo = function() {
		var date = new Date();
		var start = date.getFullYear() + "" + (date.getUTCMonth() < 10 ? "0" + date.getUTCMonth() : date.getUTCMonth()) + (date.getDay() < 10 ? "0" + date.getDay() : date.getDay()) + (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) + (date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds()) + date.getMilliseconds();
		return start;
	}
	// 事件处理对象
	this.eventUtil = {
		// 参数1：元素；参数2：时间类型（如click、focus）；参数3：回调函数；下同
		addHandler : function(oElement, sEvent, fnHandler) {
			oElement.addEventListener ? oElement.addEventListener(sEvent,
					fnHandler, false) : oElement.attachEvent("on" + sEvent,
					function() {
						fnHandler.call(oElement);
					});
		},
		removeHandler : function(oElement, sEvent, fnHandler) {
			oElement.removeEventListener ? oElement.removeEventListener(sEvent,
					fnHandler, false) : oElement.detachEvent("on" + sEvent,
					function() {
						fnHandler.call(oElement);
					});
		}
	};

	// 创建ajax引擎
	this.createAjax = function() {
		var xhr = null;
		try {
			xhr = new ActiveXObject("microsoft.xmlhttp");
		} catch (e1) {
			try {
				xhr = new XMLHttpRequest();
			} catch (e2) {
				window.alert("您的浏览器不支持ajax，请更换！");
			}
		}
		return xhr;
	};
}

function mind() {
	if(arguments.length == 1){
		return arong_element(arguments[0]);
	}else{
		return arong_element(arguments[0], arguments[1]);
	}
}
/**
 * 获取根据标签、class值、id获取Element_对象
 * @param s 选择器 @returns {Element_} 自定义的对象
 */

function arong_element() {
	var s = arguments[0];// 必选参数，代表选择器或者元素对象
	var doc = arguments[1];// 可选参数，代表选择器的父元素，默认为document
	if (doc == null)
		doc = document;
	var elements = null;
	if (s.constructor == String) {
		var sign = new arongjs().nospace(s);// 去除参数空格
		if (sign.length > 0) {
			var firstChar = sign.charAt(0);// 获取第一个字符
			var signLength = sign.length;
			if (firstChar == '#') {// 如果是ID选择器
				if(doc.getElementById(sign.substring(1, signLength))){
					elements = new Array();
					elements[0] = doc.getElementById(sign.substring(1, signLength));
				}
			}
			else if (firstChar == '.') {// 如果是类选择器
				if (document.getElementsByClassName) {
					if(document.getElementsByClassName(sign.substring(1, signLength)).length > 0){
						elements = document.getElementsByClassName(sign.substring(1, signLength));
					}
				} else {
					var alltag = doc.getElementsByTagName('*');
					var len = alltag.length;
					var selected = new Array();
					var clas;
					for ( var i = 0,j = 0; i < len; i++) {
						var t = alltag.item(i);
						if(t.className){
							clas = t.className.split(' ');
							if(clas.length > 0){
								for(j = 0; j < clas.length; j ++){
									if (clas[j] == sign.substring(1, signLength)) // 比较标签的class与所要查找的class是否相同
									{
										selected.push(t); // 将相同的存入<a
									}
								}
							}
						}
					}
					if(selected.length > 0){
						elements = selected;
					}
				}
			}
			else {// 其他，标签选择器
				var alltag = doc.getElementsByTagName(sign);
				var len = alltag.length;
				if(len > 0){
					elements = new Array();
					for ( var i = 0; i < len; i++) {
						elements.push(alltag.item(i));
					}
				}
			}
		}
	} else if (s.constructor == Array) {
		elements = s;
	} else if (typeof s == 'object') {
		elements = new Array();
		elements[0] = s;
	}
	// 返回重新封装的对象
	return elements == null ? null : new Element_(elements);
}

/**
 * 自定义的节点对象，可以增加多种方便的方法
 * @param elements
 * @returns {Element_}
 */
function Element_(elements) {
	if(elements == null){
		return null;
	}
	this.els = elements;

	this.length = elements.length;

	this.tools = $mind;//new arongjs();

	// 获取集合长度
	this.size = function() {
		return this.length;
	};

	// 获取DOM对象
	this.get = function() {
		if (arguments.length == 1) {
			return this.els[arguments[0]];
		} else {
			return this.els;
		}
	};

	// 获取/设置value值，只有表单标签才会有 val() 获取 val(value) 设置
	this.val = function() {
		if (arguments.length == 0) {
			return this.length > 0 ? this.els[0].value : null;
		} else {
			for ( var i = 0; i < this.length; i++) {
				this.els[i].value = arguments[0];
			}
			return this;
		}
	};

	// 获取第一个匹配/设置所有匹配元素的html代码
	this.html = function() {
		if (arguments.length == 0) {
			return this.length > 0 ? this.els[0].innerHTML : null;
		} else {
			for ( var i = 0; i < this.length; i++) {
				this.els[i].innerHTML = arguments[0];
			}
			return this;
		}
	};

	// 获取(所有匹配元素的文本值组合后的值)/设置所有匹配元素的text值
	this.text = function() {
		if (arguments.length == 0) {
			var text = "";
			for ( var i = 0; i < this.length; i++) {
				text += this.els[i].firstChild.nodeValue;
			}
			return text;
		} else {
			for ( var i = 0; i < this.length; i++) {
				this.els[i].firstChild.nodeValue = arguments[0];
			}
			return this;
		}
	};

	// 设置元素的style值
	this.css = function() {
		if (arguments.length == 1) {
			for ( var i = 0; i < this.length; i++) {
				if(IS_IE){
					this.els[i].style.cssText = arguments[0];
				}else{
					this.els[i].setAttribute("style", arguments[0]);
				}
			}
		} else {
			if(IS_IE){
				return this.els[0].style.cssText + ";";
			}else{
				return this.els[0].getAttribute("style");
			}
		}
		
		return this;
	};
	// 追加元素的style值
	this.cssAppend = function(cssString) {
		if(this.tools.isEmpty(cssString)){
			return this;
		}
		for ( var i = 0; i < this.length; i++) {
			if(IS_IE){
				var css_ = this.els[i].style.cssText;
				//去掉重复属性
				css_ = this.tools.styleReplace(css_, cssString);
				if(css_ == null){
					css_ = "";
				}
				if(this.tools.nospace(cssString).charAt(this.tools.nospace(cssString).length - 1) == ";"){
					this.els[i].style.cssText = cssString + css_;
				}else{
					this.els[i].style.cssText = cssString + ";" + css_;
				}
			}else{
				var css_ = this.els[i].getAttribute("style");
				//去掉重复属性
				css_ = this.tools.styleReplace(css_, cssString);
				if(css_ == null){
					css_ = "";
				}
				if(this.tools.nospace(cssString).charAt(this.tools.nospace(cssString).length - 1) == ";"){
					this.els[i].setAttribute("style", cssString + css_);
				}else{
					this.els[i].setAttribute("style", cssString + ";" + css_);
				}
			}
		}
		return this;
	};
	//获取第一个匹配元素的某个style属性值
	this.styleAttr = function(){
		if(arguments.length == 1){
			var value = null;
			var css_ = "";
			if(IS_IE){
				css_ = this.els[0].style.cssText;
			}else{
				css_ = this.els[0].getAttribute("style");
			}
			if(css_){
				var arr = css_.toLowerCase().split(";");
				for(var i = 0; i < arr.length; i++){
					if(this.tools.trim(arr[i]).indexOf(arguments[0]) == 0){
						value = arr[i].substr(arr[i].indexOf(':') + 1, arr[i].length);
					}
				}
			}
			if(value){
				value = this.tools.trim(value);
			}
			return value;
		}else{
			for ( var i = 0; i < this.length; i++) {
				mind(this.els[i]).cssAppend(arguments[0] + ":" + arguments[1] + (arguments[1].substr(arguments[1].length - 1, arguments[1].length) == ";" ? "" : ";"));
			}
			return this;
		}
	}
	//删除所有匹配元素的指定style属性
	this.removeStyleAttr = function(attr){
		for ( var l = 0; l < this.length; l++) {
			if(!mind(this.els[l]).hasStyleAttr(attr)){
				break;
			}
			if(!this.tools.isEmpty(mind(this.els[l]).css())){
				var arr = mind(this.els[l]).css().toLowerCase().split(";");
				var newstyle = "";
				for(var i = 0; i < arr.length; i++){
					if(this.tools.isEmpty(arr[i])){
						break;
					}
					var arr_ = arr[i].split(":");
					if(this.tools.trim(arr_[0]) != this.tools.trim(attr)){
						newstyle += arr[i] + ";";
					}
				}
				if(this.tools.trim(newstyle) != ""){
					mind(this.els[l]).css(newstyle);
				}
			}
		}
		return this;
	}

	// 获取属性值 attr(attrName); 获取属性值 attr(attrName,value);设置属性值
	// attr(attrName,value,fn(e));设置属性值，之后调用函数
	this.attr = function() {
		// 去除第一个参数的空格
		var argu1 = this.tools.nospace(arguments[0]);
		if (arguments.length == 1) {
			if (this.length > 0) {
				if (argu1 == "style") {
					return this.els[0].style.cssText;
				} else if (argu1 == "class") {
					return this.els[0].className;
				} else {
					return this.els[0].getAttribute(argu1);
				}
			} else {
				return null;
			}
		} else if (arguments.length == 2) {
			if (argu1 == "style") {
				for ( var i = 0; i < this.length; i++) {
					this.els[i].style.cssText = arguments[1];
				}
			} else if (argu1 == "class") {
				for ( var i = 0; i < this.length; i++) {
					this.els[i].className = arguments[1];
				}
			} else {
				for ( var i = 0; i < this.length; i++) {
					this.els[i].setAttribute(argu1, arguments[1]);
				}
			}
			return this;
		} else if (arguments.length == 3) {
			for ( var i = 0; i < this.length; i++) {
				if (argu1 == "style") {
					this.els[i].style.cssText = arguments[1];
				} else if (argu1 == "class") {
					this.els[i].className = arguments[1];
				} else {
					this.els[i].setAttribute(argu1, arguments[1]);
				}
			}
			// 执行回调函数
			arguments[2](this);
			return this;
		}
	};

	// 删除指定名称的属性
	this.removeAttr = function(attrName) {
		for ( var i = 0; i < this.length; i++) {
			if (attrName == "style") {
				this.els[i].style.cssText = "";
			} else if (attrName == "class") {
				this.els[i].className = "";
			} else {
				return this.els[i].setAttribute(attrName, "");
			}
		}
		return this;
	};

	// 为每个匹配的元素添加指定的类名。
	this.addClass = function() {
		if(arguments[0]){
			for ( var i = 0; i < this.length; i++) {
				this.els[i].className = this.els[i].className + " " + arguments[0];
			}
		}
		if(arguments[1]){
			arguments[1](this);
		}
		return this;
	};

	// 为每个匹配的元素删除指定的类名。
	this.removeClass = function() {
		if(arguments[0]){
			for ( var i = 0; i < this.length; i++) {
				this.els[i].className = this.els[i].className.replace(arguments[0],"");
			}
		}
		if(arguments[1]){
			arguments[1](this);
		}
		return this;
	};
	
	// 如果存在（不存在）就删除（添加）一个类。
	this.toggleClass = function() {
		if(arguments[0]){
			// 去除参数的空格
			var classTemp = this.tools.nospace(arguments[0]);
			
			var currentClass = null;
			for ( var i = 0; i < this.length; i++) {
				// 获取当前的class值
				currentClass = this.els[i].className;
				// 如果含有指定的类，则删除
				if (this.tools.contains(currentClass.split(/ +/i), classTemp)) {
					this.els[i].className = currentClass.replace(classTemp, "");
				}
				// 否则添加
				else {
					this.els[i].className = currentClass + " " + classTemp;
				}
			}
		}
		if(arguments[1]){
			arguments[1](this);
		}
		return this;
	};
	//向每个匹配的元素中追加内容元素
	this.append = function(){
		if(arguments[0]){
			for ( var i = 0; i < this.length; i++) {
				if(arguments[0].constructor == String){
					this.els[i].innerHTML = this.els[i].innerHTML + arguments[0];
				}else{
					this.els[i].appendChild(arguments[0]);
				}
			}
		}
		if(arguments[1]){
			arguments[1](this);
		}
	}
	//删除自身?强悍啊
	this.remove = function(){
		for ( var i = 0; i < this.length; i++) {
			this.parent().get(0).removeChild(this.els[i]);
		}
	}
	//获取第一个匹配元素的宽度
	this.width = function(){
		return this.els[0].clientWidth;
	}
	//获取第一个匹配元素的高度
	this.height = function(){
		return this.els[0].clientHeight;
	}
	//获取第一个匹配元素距浏览器左端的像素值
	this.offsetLeft = function(){
		return this.els[0].offsetParent ? (this.els[0].offsetLeft + mind(this.els[0].offsetParent).offsetLeft()) : this.els[0].offsetLeft;
	}
	//获取第一个匹配元素距浏览器顶端的像素值
　　    this.offsetTop = function(){
		return this.els[0].offsetParent ? (this.els[0].offsetTop + mind(this.els[0].offsetParent).offsetTop()) : this.els[0].offsetTop;
　　    }
	
	// 筛选
	// 过滤

	this.eq = function(index) {
		return mind(this.els[index]);
	};

	this.first = function() {
		return mind(this.els[0]);
	};

	this.last = function() {
		return mind(this.els[this.length - 1]);
	};

	// 检查当前的元素是否含有某个特定的类，如果有，则返回true。
	this.hasClass = function(classString) {
		var className = this.els[0].className;
		return this.tools.contains(className.split(" "), classString);
	};
	
	// 检查当前的元素的style是否含有某个指定的属性，如果有，则返回true。
	this.hasStyleAttr = function(attr) {
		if(this.tools.isEmpty(attr)){
			return false;
		}
		var style = this.css();
		if(this.tools.isEmpty(style)){
			return false;
		}
		var arr = style.split(";");
		if(arr.length > 0){
			for(var i = 0; i < arr.length; i++){
				if(!this.tools.isEmpty(arr[i])){
					var arr_ = arr[i].toLowerCase().split(":");
					if(arr_.length == 2 && this.tools.trim(arr_[0]) == this.tools.trim(attr)){
						return true;
					}
				}
			}
		}
		return false;
	};
	
	// 查找
	// 获取第一个匹配元素的所有子元素
	this.children = function() {
		var childs = this.els[0].childNodes;//某些元素具有隐藏元素，比如table下会自动包含tbody元素
		if(arguments[0]){
			if(this.els[0].nodeName.toLowerCase() == "table"){
				childs =this.els[0].childNodes[0].childNodes;
			}
		}
		if(childs.length > 0){
			var childs_ = new Array();
			for(var i = 0; i < childs.length; i++){
				//一些浏览器会把回车换行也当做子元素，过滤掉
				if(!(childs[i].nodeName == "#text" && !/\s/.test(childs.nodeValue))){
					childs_.push(childs[i]);
				}
			}
			if(childs_.length > 0){
				return mind(childs_);
			}
		}
		return null;
	};
	
	//获取第一个匹配元素的父元素
	this.parent = function(){
		if(this.els[0].parentNode){
			return mind(this.els[0].parentNode);
		}
		return null;
	}
	
	//查找第一个匹配元素的子元素，目前只能按标签名查找，日后完善
	this.find = function(s) {
		return mind(s, this.els[0]);
	};

	// 事件********
	// 绑定
	this.bind = function(type, fn) {
		for ( var i = 0; i < this.length; i++) {
			this.tools.eventUtil.addHandler(this.els[i], type, fn);
		}
		return this;
	};
	
	// 解绑定
	this.unbind = function(type, fn) {
		for ( var i = 0; i < this.length; i++) {
			this.tools.eventUtil.removeHandler(this.els[i], type, fn);
		}
		return this;
	};

	// 加载
	this.ready = function(fn) {
		this.tools.eventUtil.addHandler(window, "load", fn);
		return this;
	};

	// 单击
	this.click = function() {
		if (arguments.length == 0) {
			for ( var i = 0; i < this.length; i++) {
				this.els[i].click();
			}
		} else {
			for ( var i = 0; i < this.length; i++) {
				this.tools.eventUtil.addHandler(this.els[i], "click",
						arguments[0]);
			}
		}
		return this;
	};

	// 双击
	this.dblclick = function(fn) {
		for ( var i = 0; i < this.length; i++) {
			this.tools.eventUtil.addHandler(this.els[i], "dblclick", fn);
		}
		return this;
	};

	// 失去焦点
	this.blur = function(fn) {
		for ( var i = 0; i < this.length; i++) {
			this.tools.eventUtil.addHandler(this.els[i], "blur", fn);
		}
		return this;
	};

	// 得到焦点
	this.focus = function(fn) {
		for ( var i = 0; i < this.length; i++) {
			this.tools.eventUtil.addHandler(this.els[i], "focus", fn);
		}
		return this;
	};

	// 下拉框选择改变
	this.change = function(fn) {
		for ( var i = 0; i < this.length; i++) {
			this.tools.eventUtil.addHandler(this.els[i], "change", fn);
		}
		return this;
	};

	// 键盘键弹起
	this.keyup = function(fn) {
		for ( var i = 0; i < this.length; i++) {
			this.tools.eventUtil.addHandler(this.els[i], "keyup", fn);
		}
		return this;
	};

	// 键盘键按下
	this.keydown = function(fn) {
		for ( var i = 0; i < this.length; i++) {
			this.tools.eventUtil.addHandler(this.els[i], "keydown", fn);
		}
		return this;
	};

	// 键盘键按着(只能针对字符型按键)
	this.keypress = function(fn) {
		for ( var i = 0; i < this.length; i++) {
			this.tools.eventUtil.addHandler(this.els[i], "keypress", fn);
		}
		return this;
	};

	// 鼠标按下
	this.mousedown = function(fn) {
		for ( var i = 0; i < this.length; i++) {
			this.tools.eventUtil.addHandler(this.els[i], "mousedown", fn);
		}
		return this;
	};

	// 鼠标移动
	this.mousemove = function(fn) {
		for ( var i = 0; i < this.length; i++) {
			this.tools.eventUtil.addHandler(this.els[i], "mousemove", fn);
		}
		return this;
	};

	// 鼠标移出元素
	this.mouseout = function(fn) {
		for ( var i = 0; i < this.length; i++) {
			this.tools.eventUtil.addHandler(this.els[i], "mouseout", fn);
		}
		return this;
	};

	// 鼠标移入元素
	this.mouseover = function(fn) {
		for ( var i = 0; i < this.length; i++) {
			this.tools.eventUtil.addHandler(this.els[i], "mouseover", fn);
		}
		return this;
	};

	// 鼠标点击元素（左键或右键）
	this.mouseup = function(fn) {
		for ( var i = 0; i < this.length; i++) {
			this.tools.eventUtil.addHandler(this.els[i], "mouseup", fn);
		}
		return this;
	};

	// 当滚动条发生变化时触发--与jquery一样，只实现了处理IE的window对象，而不能处理document
	this.scroll = function(fn) {
		for ( var i = 0; i < this.length; i++) {
			this.tools.eventUtil.addHandler(this.els[i], "scroll", fn);
		}
		return this;
	};

	// 当用户在文本框(包括input和textarea)中选中某段文本时会触发select事件。
	this.select = function(fn) {
		for ( var i = 0; i < this.length; i++) {
			this.tools.eventUtil.addHandler(this.els[i], "select", fn);
		}
		return this;
	};

	// submit事件将会在表单提交时触发
	this.submit = function(fn) {
		for ( var i = 0; i < this.length; i++) {
			this.tools.eventUtil.addHandler(this.els[i], "submit", fn);
		}
		return this;
	};
	
	// selectstart事件将会在光标选中文字是触发
	this.selectstart = function(fn) {
		for ( var i = 0; i < this.length; i++) {
			this.tools.eventUtil.addHandler(this.els[i], "selectstart", fn);
		}
		return this;
	};
	
	//实现对元素的拖动，其中node为mind对象，表示可拖动的元素
	this.moveNode = function() {
		var flag = false;
		var node = arguments.length == 0 ? this : arguments[0];
		var ele = this.els[0];
		var mouseDownPosiX;
		var mouseDownPosiY;
		var InitPositionX = node.styleAttr("left");
		var InitPositionY = node.styleAttr("top");
		//为了兼容IE移动时会将部分边框隐藏
		var border = node.styleAttr("border");
		var radius = node.styleAttr("border-radius");
		var style = "";
		if(border && radius){
			node.removeStyleAttr("border-radius");//删除border-radius属性，不然会影响border的值
			style = "border:" + node.styleAttr("border") + ";border-radius:" + radius + ";";
		}
		if(!InitPositionX){
			style += "left:" + (document.body.scrollWidth) / 2 + "px;";
		}
		if(!InitPositionY){
			style += "top:" + node.offsetTop() + "px;";
		}
		style += "position:absolute;";
		node.cssAppend(style);
		mind(ele).mousedown(function(e1) {
			// 当鼠标按下时捕获鼠标位置以及对象的当前位置
			flag = true;
			var e = e1 || window.event; 
			mouseDownPosiX = IS_IE ? e.clientX : e.pageX;
			mouseDownPosiY = IS_IE ? e.clientY : e.pageY;
			InitPositionX = node.styleAttr("left") ? node.styleAttr("left").replace("px", "") : mouseDownPosiX;
			InitPositionY = node.styleAttr("top") ? node.styleAttr("top").replace("px", "") : mouseDownPosiY;
		});
		mind(document).mousemove(function(e2) {
			if(flag){
				var e = e2 || window.event;
				var tempX = parseInt(IS_IE ? e.clientX + 2 : e.pageX) - parseInt(mouseDownPosiX) + parseInt(InitPositionX);
				var tempY = parseInt(IS_IE ? e.clientY + 2 : e.pageY) - parseInt(mouseDownPosiY) + parseInt(InitPositionY);
				node.cssAppend("left:" + tempX + "px;top:" + tempY + "px;" + style);
				//拖动模式下不能选中文字，兼容IE(再此IE开启后不能恢复了，待解决)&Chrome
				if(!IS_IE){
					mind(document).selectstart(function(e3){
						var e = e3 || window.event;
						e.returnValue = false;
					});
				}
				//firefox不能选中文字
				mind("body").cssAppend("-moz-user-select:none;");
			}
		});
		mind(document).mouseup(function() {
			flag = false;
			mind(document).selectstart(function(e3){
				var e = e3 || window.event;
				e.returnValue = true;
			});
			mind("body").cssAppend("-moz-user-select:text;");
		});
		return this;
	}
	// 事件结束

	// 元素异步加载数据
	this.load = function(conf) {
		var url = conf.url;
		var data = conf.data;
		var success = conf.success;
		var type = "get";
		if (data != null)
			type = "post";
		// 模拟load方式
		this.tools.ajax({
			url : url,
			type : type,
			data : data,
			element : this
		});
		if (success != null)
			success(this);
		return this;
	};
}